﻿<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="CourseForm.ascx.cs" Inherits="AcademicPlanner.Presentation.Views.Shared.CourseForm" %>
<%@ Import Namespace="AcademicPlanner.Framework.Libraries.Mvc" %>
<%@ Import Namespace="AcademicPlanner.Framework.Helpers" %>
<%@ Import Namespace="AcademicPlanner.Presentation" %>
<%@ Import Namespace="AcademicPlanner.Presentation" %>
<%@ Import Namespace="AcademicPlanner.Presentation.Views.Shared" %>
<%@ Import Namespace="AcademicPlanner.Domain.Models" %>

<% if (!Model.IsSub)
   { %>
		<div class="form yui-skin-sam">
		<% Begin(); %>
<% } %>

<% if (!string.IsNullOrEmpty(Title))
   { %>
		<fieldset><legend><%= Html.Encode(Title) %></legend>
<% } %>

<% if (!Model.IsSub)
   { %>
		<%= WidgetHelper.FormErrorsBlock("", Model.Id + "Errors", "hidden")%>
<% } %>



<% if (Model.Scenario == CourseFormScenario.CREATE
		|| Model.Scenario == CourseFormScenario.EDIT)
   {
	%>
		<div class="rows-wrapper">
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("Name"), Html.Encode(Tr(Labels.Get("Name", "Course"))), true)%>
				</div>
				<div class="cell">
					<%= Html.TextField(GetFieldName("Name"), NameValue)%>
				</div>
			</div>
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("Number"), Html.Encode(Tr(Labels.Get("Number", "Course"))), true)%>
				</div>
				<div class="cell">
					<%= Html.TextField(GetFieldName("Number"), NumberValue)%>
				</div>
				<div class="cell">
					<span class="hint"><%= Html.Encode(string.Format(Tr("greater than {0}"),
					                   					Course.NUMBER_MIN_VALUE)) %></span>
				</div>
			</div>
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("Credits"), Html.Encode(Tr(Labels.Get("Credits", "Course"))), true)%>
				</div>
				<div class="cell">
					<%= Html.TextField(GetFieldName("Credits"), CreditsValue)%>
				</div>
				<div class="cell">
					<span class="hint"><%= Html.Encode(string.Format(Tr("greater than {0}"),
					                   					Course.CREDITS_MIN_VALUE)) %></span>
				</div>
			</div>
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("Category"), Html.Encode(Tr(Labels.Get("Category", "Course"))), true)%>
				</div>
				<div class="cell">
					<%	if (CategoryOptions.Count > 0)
						{ %>
						<%= Html.DropDownList(GetFieldName("Category"), CategoryOptions)%>
					<%	} 
						else 
						{ %>
							<a href="<%= Url.Action("Overview", "MyPlan") %>#planSettings=edit">
								<%= Tr("Click here") %></a>
							to add Divisions and Categories first!
						<% } %>
				</div>
			</div>
			<%	if (SelectPrerequisiteCoursesModel.Courses.Count > 0)
				{ %>
					<div class="row">
						<div class="cell label">
							<%= Html.Label(GetFieldName("Prerequisites"), Html.Encode(Tr(Labels.Get("Prerequisites", "Course"))))%>
						</div>
						<div class="cell">
							<% Html.RenderPartial("CoursesControl", SelectPrerequisiteCoursesModel); %>
						</div>
					</div>
				<% } %>
			<div class="row">
				<div class="cell label">
					<%= Html.Label(GetFieldName("CommonlyOfferedInTerms"), Html.Encode(Tr(Labels.Get("CommonlyOfferedInTerms", "Course"))))%>
				</div>
				<div class="cell">
					<%	if (SelectCommonlyOfferedInTermsModel.AcademicTerms.Count > 0)
						{ %>
						<% Html.RenderPartial("AcademicTermsControl", SelectCommonlyOfferedInTermsModel); %>
					<%	} 
						else 
						{ %>
							<a href="<%= Url.Action("Overview", "MyPlan") %>#planSettings=edit">
								<%= Tr("Click here") %></a>
							to add Terms first!
						<% } %>
				</div>
			</div>
		</div>
<% } %>



<% if (!Model.IsSub)
   { %>
		<div class="rows-wrapper action">
			<div class="row">
				<div class="cell label">
					&nbsp;
				</div>
				<div class="cell">
					<%= Html.SubmitButton("submitForm", Html.Encode(SubmitButtonValue), "") %>
				</div>
			</div>
		</div>
<% } %>


<% if (!string.IsNullOrEmpty(Title))
   { %>
		</fieldset>
<% } %>


<% if (!Model.IsSub)
   { %>
		<% End(); %>
		</div>
<% } %>